#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

import sys
import os

abspath = os.path.abspath(sys.argv[1])
basename = os.path.basename(abspath)
name = basename[:-7]
print("Uncompressing " + basename + " ... "),
os.system("mkdir " + basename[:-7])
os.system("tar zxf " + sys.argv[1] + " -C " + basename[:-7])
print("Done.")
print("Deleting useless files ... "),
os.system("rm -f " + abspath[:-7] + "/SRA_*")
print("Done.")
print("Deleting original files ... "),
os.system("rm -f " + abspath)
print("Done.")
print("Compressing files ... "),
os.system("tar czf " + basename + " " + basename[:-7])
print("Done.")
print("Deleting useless files ... "),
os.system("rm -rf " + abspath[:-7])
print("Done.")
